var express = require('express');
var bodyParser = require('body-parser')
const verifymiddleware = require('./routes/middleware')
var app = express();
var indexRouter = require('./routes/index')
var wishRouter = require('./routes/wish')
var adminRouter = require('./routes/admin')



//设置允许跨域访问该服务.
//设置跨域访问
app.all('*', function (req, res, next) {
  res.setHeader("Access-Control-Allow-Origin", "*");
  res.setHeader("Access-Control-Allow-Headers", "*");
  // res.setHeader("Access-Control-Allow-Methods", "*");

  next();
});
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use('/', indexRouter) |
app.use('/admin', verifymiddleware.VerifyToken, adminRouter)
app.use('/wish', verifymiddleware.VerifyToken, wishRouter)

module.exports = app;
